﻿/*
 * Copyright 2014 Francois Karman
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;

namespace Quartz.WebManager.Model
{
    /// <summary>
    /// Tests the <see cref="JobDetail"/> class.
    /// </summary>
    [TestClass]
    public class JobDetailTest
    {
        /// <summary>
        /// Tests the <see cref="JobDetail"/> constructor.
        /// </summary>
        [TestMethod]
        public void Constructor()
        {
            JobDetail instance = new JobDetail();
            Assert.IsNotNull(instance.Properties);
            Assert.IsNotNull(instance.Triggers);
        }

        /// <summary>
        /// Tests the <see cref="JobDetail.Definition"/> property.
        /// </summary>
        [TestMethod]
        public void Definition()
        {
            JobDefinition definition = new JobDefinition();
            definition.Properties.Add(new DataPropertyInfo() { Name = "test property 1" });
            definition.Properties.Add(new DataPropertyInfo() { Name = "test property 2" });

            JobDetail instance = new JobDetail();
            Assert.AreEqual(0, instance.Properties.Count);

            instance.Definition = definition;
            Assert.AreEqual(2, instance.Properties.Count);
            CollectionAssert.AreEquivalent(new[] { "test property 1", "test property 2" }, instance.Properties.Keys.ToList());
            Assert.IsNull(instance.Properties["test property 1"]);
            Assert.IsNull(instance.Properties["test property 2"]);
        }
    }
}
